package mega.privacy.android.domain.usecase

import com.google.common.truth.Truth.assertThat
import kotlinx.coroutines.test.runTest
import mega.privacy.android.domain.repository.VerificationRepository
import org.junit.jupiter.api.AfterEach
import org.junit.jupiter.api.BeforeEach
import org.junit.jupiter.api.TestInstance
import org.junit.jupiter.params.ParameterizedTest
import org.junit.jupiter.params.provider.NullSource
import org.junit.jupiter.params.provider.ValueSource
import org.mockito.Mockito.mock
import org.mockito.kotlin.reset
import org.mockito.kotlin.whenever

@TestInstance(TestInstance.Lifecycle.PER_CLASS)
class GetCurrentCountryCodeUseCaseTest {

    private lateinit var underTest: GetCurrentCountryCodeUseCase

    private val verificationRepository: VerificationRepository = mock()

    @BeforeEach
    fun setup() {
        underTest = GetCurrentCountryCodeUseCase(verificationRepository)
    }

    @ParameterizedTest
    @ValueSource(strings = ["62"])
    @NullSource
    fun `test that the use case returns the same country code value as the repository`(expected: String?) =
        runTest {
            whenever(verificationRepository.getCurrentCountryCode()).thenReturn(expected)

            val actual = underTest()

            assertThat(actual).isEqualTo(expected)
        }

    @AfterEach
    fun tearDown() {
        reset(verificationRepository)
    }
}
